#!/usr/bin/env python3
"""
二维码Pydantic模式
"""

from datetime import datetime
from typing import Any

from pydantic import BaseModel, Field


class QRCodeBase(BaseModel):
    """二维码基础模型"""

    visitor_id: int = Field(..., description="访客ID")
    qr_code: str = Field(..., description="二维码数据")


class QRCodeRequest(BaseModel):
    """二维码请求模型"""

    visitor_id: int | None = Field(None, description="访客ID")
    qr_code: str | None = Field(None, description="二维码数据")


class QRCodeResponse(BaseModel):
    """二维码响应模型"""

    qr_code: str = Field(..., description="二维码数据")
    visitor_id: int = Field(..., description="访客ID")
    visitor_name: str = Field(..., description="访客姓名")
    message: str = Field(..., description="操作消息")
    verification_result: dict[str, Any] | None = Field(None, description="验证结果")
    created_at: datetime | None = Field(None, description="创建时间")
    expire_time: datetime | None = Field(None, description="过期时间")

    class Config:
        from_attributes = True


class QRCodeListResponse(BaseModel):
    """二维码列表响应模型"""

    qrcodes: list[QRCodeResponse] = Field(..., description="二维码列表")
    total: int = Field(..., description="总数")
    skip: int = Field(..., description="跳过数量")
    limit: int = Field(..., description="限制数量")
